package com.tfswue.mxj.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {
    // 允许匿名访问的首页
    @GetMapping("/")
    public String home() {
        return "Welcome! <a href='/user/hello'>User Page</a> | <a href='/admin/hello'>Admin Page</a>";
    }
    // 公共接口（无需认证）
    @GetMapping("/public/hello")
    public String publicHello() {
        return "Hello Public!";
    }

    // 需要 USER 角色的接口
    @GetMapping("/user/hello")
    public String userHello() {
        return "Hello User!";
    }

    // 需要 ADMIN 角色的接口
    @GetMapping("/admin/hello")
    public String adminHello() {
        return "Hello Admin!";
    }

    // 登出提示
    @GetMapping("/public/goodbye")
    public String goodbye() {
        return "You have been logged out!";
    }
}

